#pragma once
#include "stdafx.h"
#include "CommuEasyDef.h"

#define COMMEASY_EXPORTS 1

#ifdef COMMEASY_EXPORTS
#define COMMEASY_API __declspec(dllexport)
#else
#define COMMEASY_API __declspec(dllimport)
#endif


COMMEASY_API
HANDLE
commeasy_Create(UINT nNumberOfThreads /*= 0*/);

COMMEASY_API
BOOL
commeasy_ListenW(HANDLE hCommEasy, LPCWSTR lpszLocalAddress);

COMMEASY_API
BOOL
commeasy_Listen6W(HANDLE hCommEasy, LPCWSTR lpszLocalAddress);

COMMEASY_API
void
commeasy_StopListen(HANDLE hCommEasy);

COMMEASY_API
void
commeasy_StopListen6(HANDLE hCommEasy);

COMMEASY_API
PSEUDOSOCKET
commeasy_ConnectW(HANDLE hCommEasy, LPCWSTR lpszRemoteAddress, LPCWSTR lpszLocalAddress);

COMMEASY_API
PSEUDOSOCKET
commeasy_Connect6W(HANDLE hCommEasy, LPCWSTR lpszRemoteAddress, LPCWSTR lpszLocalAddress);

COMMEASY_API
BOOL
commeasy_SendPack(HANDLE hCommEasy, PSEUDOSOCKET nPseudoSock, LPVOID lpData, ULONG nDataLength);

COMMEASY_API
ULONG
commeasy_Send(HANDLE hCommEasy, PSEUDOSOCKET nPseudoSock, LPVOID lpData, ULONG nDataLength);

COMMEASY_API
BOOL
commeasy_SendToPack(HANDLE hCommEasy, PSEUDOSOCKET nPseudoSock, LPVOID lpData, ULONG nDataLength);

COMMEASY_API
BOOL
commeasy_SendTo(HANDLE hCommEasy, PSEUDOSOCKET nPseudoSock, LPVOID lpData, ULONG nDataLength);

COMMEASY_API
BOOL
commeasy_TransmitFile(HANDLE hCommEasy, PSEUDOSOCKET nPseudoSock, HANDLE hFile, ULONGLONG nOffset, ULONG nNumberOfBytes);

COMMEASY_API
BOOL
commeasy_DisConnect(HANDLE hCommEasy, PSEUDOSOCKET nPseudoSock);

COMMEASY_API
BOOL
commeasy_GetAddress(HANDLE hCommEasy, PSEUDOSOCKET nPseudoSock, PSOCKADDR_INET lpstLocalAddr, PSOCKADDR_INET lpstRemoteAddr);

COMMEASY_API
ULONGLONG
commeasy_GetConnectedCount(HANDLE hCommEasy);

COMMEASY_API
void
commeasy_Release(HANDLE hCommEasy);

COMMEASY_API
void
commeasy_SetAcceptCallback(HANDLE hCommEasy, LPFNCOMMUEASY_ROUTINE_ACCEPT lpFnRoutine, LPVOID lpCallbackData);

COMMEASY_API
void
commeasy_SetRecvPackCallback(HANDLE hCommEasy, LPFNCOMMUEASY_ROUTINE_RECVPACK lpFnRoutine, LPVOID lpCallbackData);

COMMEASY_API
void
commeasy_SetRecvCallback(HANDLE hCommEasy, LPFNCOMMUEASY_ROUTINE_RECV lpFnRoutine, LPVOID lpCallbackData);

COMMEASY_API
void
commeasy_SetSendToPackCallback(HANDLE hCommEasy, LPFNCOMMUEASY_ROUTINE_SENDTOPACK lpFntRoutine, LPVOID lpCallbackData);

COMMEASY_API
void
commeasy_SetSendToCallback(HANDLE hCommEasy, LPFNCOMMUEASY_ROUTINE_SENDTO lpFntRoutine, LPVOID lpCallbackData);

COMMEASY_API
void
commeasy_SetTransmitFileCallback(HANDLE hCommEasy, LPFNCOMMUEASY_ROUTINE_TRANSMITFILE lpFntRoutine, LPVOID lpCallbackData);

COMMEASY_API
void
commeasy_SetCloseCallback(HANDLE hCommEasy, LPFNCOMMUEASY_ROUTINE_CLOSE lpFnRoutine, LPVOID lpCallbackData);

COMMEASY_API
HANDLE
commeasy_client_Create();

COMMEASY_API
BOOL
commeasy_client_ConnectW(HANDLE hCommEasy, LPCWSTR lpszRemoteAddress, LPCWSTR lpszLocalAddress = NULL);

COMMEASY_API
BOOL
commeasy_client_Connect6W(HANDLE hCommEasy, LPCWSTR lpszRemoteAddress, LPCWSTR lpszLocalAddress = NULL);

COMMEASY_API
BOOL
commeasy_client_SendPack(HANDLE hCommEasy, LPVOID lpData, ULONG nDataLength);

COMMEASY_API
ULONG
commeasy_client_Send(HANDLE hCommEasy, LPVOID lpData, ULONG nDataLength);

COMMEASY_API
BOOL
commeasy_client_RecvPack(HANDLE hCommEasy, LPWSABUF lpstBuf);

COMMEASY_API
ULONG
commeasy_client_Recv(HANDLE hCommEasy, LPVOID lpBuffer, ULONG nSize);

COMMEASY_API
ULONG
commeasy_client_ReceiveFile(HANDLE hCommEasy, HANDLE hFile, ULONGLONG nOffset, ULONG nNumberOfBytes);

COMMEASY_API
BOOL
commeasy_client_SetTimeout(HANDLE hCommEasy, DWORD nMilliseconds, BOOL bReceive);

COMMEASY_API
void
commeasy_client_GetAddress(HANDLE hCommEasy, PSOCKADDR_INET lpstLocalAddr, PSOCKADDR_INET lpstRemoteAddr);

COMMEASY_API
void
commeasy_client_DisConnect(HANDLE hCommEasy);

COMMEASY_API
void
commeasy_client_Release(HANDLE hCommEasy);